package web.servlet;

import service.ProvinceService;
import service.impl.ProvinceServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Mc.Chai
 * @program: JavaWeb
 * @create 2022-04-23-15:40 15:40
 */
@WebServlet("/findProvinceServlet")
public class FindProvinceServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //使用json数据格式
        response.setContentType("application/json;charset=utf-8");

        ProvinceService service = new ProvinceServiceImpl();
        String allJson = service.findAllJson();
        response.getWriter().write(allJson);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
